Commit Graph

11283 Commits

Author SHA1 Message Date
Matthias Clasen
4417509515 dmabuf: Add a display getter
Add private api to get the display of
a dmabuf texture. We will need it in
the following commit.
2023-10-16 22:29:20 -04:00
Matthias Clasen
9dc2e554e5 dmabuf: Tweak error messages 2023-10-16 22:29:10 -04:00
Benjamin Otte
570e80a9ff dmabuf: Split out GdkDmabuf and GdkDmabufDownloader
GdkDmabuf is a struct encapsulating all the values of a dmabuf, so
nothing to see here.

GdkDmabufDownloader is a vtable for a thing that can download dmabufs.
For now only one implementation exists, so this just looks like a ton
of work for no benefit.

The only neat thing is that gdkdmabuftexture.c got a whole lot tidier.
2023-10-16 18:56:52 -04:00
Matthias Clasen
2f842b087c dmabuf: Cosmetics 2023-10-15 12:00:23 -04:00
Matthias Clasen
699f6a7993 Add a dmabuf debug flag
Add a new debug flag for dmabuf-related information,
and use it in gdkdmabuftexture.c.

This will let us separate out dmabuf debug spew from
opengl debug spew.
2023-10-15 11:05:32 -04:00
Matthias Clasen
9f8d34ab01 dmabufformatsbuilder: Make it work
The qsort arguments were mixed up, leading to nonsense.
2023-10-14 23:04:00 -04:00
Benjamin Otte
57d8cc08a3 gdk: Add GDK_DEBUG=dmabuf-disable
I chose the name for consistency with gl-disable and vulkan-disable.
2023-10-14 22:30:17 +02:00
Benjamin Otte
1ca067a478 dmabuf: Add a GError to gdk_dmabuf_texture_builder_build() 2023-10-14 22:30:17 +02:00
Benjamin Otte
7a13e4f9b9 docs: Remove docs for private GdkDmabufFormat struct
This is a leftover from the design of the GdkDmabufFormats struct.
2023-10-14 22:30:17 +02:00
Benjamin Otte
d101e17608 dmabuf: Use the new FormatsBuilder to initialize formats 2023-10-14 22:30:17 +02:00
Benjamin Otte
203a4fc45e dmabufformats: Add GdkDmabufFormatsBuilder
This is a utility object that helps in constructing GdkDmabufFormats.
2023-10-14 22:29:10 +02:00
Benjamin Otte
a9823e05bb array: constify the additions array
We can only do that for by-value arrays, because compilers get confused
with const when there's too many dereferences going on.
2023-10-14 22:11:44 +02:00
Benjamin Otte
6f5833df28 dmabufformats: Mark a bunch of functions as pure 2023-10-14 22:11:44 +02:00
Benjamin Otte
e584d17aad Merge branch 'dmabuf-texture-api' into 'main'
Add API for dmabuf textures

See merge request GNOME/gtk!6463
2023-10-11 20:25:50 +00:00
Matthias Clasen
4936965fb6 display: Get supported dmabuf formats
These are the dmabuf formats that we can import
into a GL context as an EGLImage, and successfully
download.

We skip the GdkDisplay:dmabuf-formats property
in the default value tests, since the nominal
default value is NULL, but the actual value is
constructed on demand.
2023-10-11 15:43:01 -04:00
Matthias Clasen
c93efe85dd Add GdkDmabufTexture
Add an implementation of GdkDmabufTexture.

For now, this implementation is rather minimal,
since we need a roundtrip through GL to convert
most nottrivial formats.
2023-10-11 15:43:01 -04:00
Matthias Clasen
d23e13aced Add GdkDmabufTextureBuilder
Add a builder for a new GdkTexture subclass that
wraps dmabuf buffers on Linux. For now, this is
just an API. The implementation will follow in
subsequent commits.
2023-10-11 14:54:21 -04:00
Matthias Clasen
40102a2b61 Add GdkDmabufFormats
This is an immutable struct containing information
about supported dma-buf formats and their properties.
2023-10-11 14:53:06 -04:00
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
Luca Bacci
822425072b Merge branch '5724_gdk_win32_ignore_invalid_client_rect' into 'main'
Gdk4 Win32: ignore invalid client rects

Closes #5724

See merge request GNOME/gtk!6414
2023-10-04 07:58:55 +00:00
Jonas Ådahl
c86bc00330 Merge branch 'master' into 'main'
GdkSurface: prevent popups from appearing offscreen in edge cases

See merge request GNOME/gtk!5320
2023-09-30 15:03:33 +00:00
Emmanuele Bassi
79ebd76ac8 Merge branch 'wip/chergert/fix-gdkarrayimpl-from-c++' into 'main'
gdk: add missing G_END_DECLS to gdkarrayimpl.c

See merge request GNOME/gtk!6435
2023-09-26 18:48:02 +00:00
Christian Hergert
6eb9836eb0 gdk: add missing G_END_DECLS to gdkarrayimpl.c 2023-09-26 10:46:21 -07:00
Emmanuele Bassi
0b64fa88a1 docs: Clarify the behaviour of gdk_texture_new_for_surface()
Cairo surfaces are not GObject instances, so we should be more explicit
in the behaviour of the memory management, to avoid leaks.
2023-09-26 12:57:52 +01:00
Benjamin Otte
e720008dca glcontext: Add gdk_gl_context_get_glsl_version_string()
This is in preparation for the new renderer.
2023-09-26 11:08:59 +02:00
Benjamin Otte
9c636a6136 array: Compute new size properly
Using "1 << x" means that we are shifting a signed 32bit integer, but we
want a gsize, which is an unsigned 64bit integer.

So now we don't overflow anymore if the array reaches a size of 2GB.
2023-09-26 11:08:59 +02:00
Benjamin Otte
1e24aa425e gdk: Fix compiler warning
gcc's -Wlto-type-mismatch found the hack, where we copied the wrong
prototype.
2023-09-26 11:08:59 +02:00
Matthias Clasen
18fbec0fe1 Improve FOO_DEBUG=help output
Explain the all value a bit better.
2023-09-24 08:33:22 -04:00
kramo
0b2cebe3d8
docs: Update cursor images 2023-09-21 19:51:11 +02:00
Luca Bacci
347b0317e5 Merge branch 'fix-issue-6080' into 'main'
GdkWin32: Unref GdkMonitor after calling gdk_monitor_invalidate ()

Closes #6080

See merge request GNOME/gtk!6411
2023-09-21 12:41:55 +00:00
G.Willems
4c46f5a8f7 GdkWin32: ignore invalid client rects
Gdk-Win32 uses GetClientRect() internally to query the surfaces coordinates,
but this API may fail in some transient contexts (observed when iconifying
a maximized window).
Check if the rect area is null, and don't update the surface position in
that case. This will keep the current surface size, until Win32 notifies
the new valid window state later.
This prevents using a nulled next_layout for toplevel size computation,
which would break widgets allocation once notified on gtk side.

Fixes #5724
Closes #5724
2023-09-19 20:29:04 +02:00
Luca Bacci
17c59d6da6 GdkWin32: Unref GdkMonitor after calling gdk_monitor_invalidate ()
Ensure that we have a reference when calling gdk_monitor_invalidate ()

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6080
2023-09-19 18:46:41 +02:00
Carlos Garnacho
14d99bacbc gdk/wayland: Use toplevel surface for activation
At the moment of launching/activating an application, the
keyboard focus may be on a transient surface that quickly
disappears after activation. If this happens, and the
compositor handles surface destruction before the activated
application gets to reply, the activation request may be
deemed outdated, and the "demands attention" paths be taken.

Peek the toplevel from the focus surface, as that has larger
guarantees to remain valid for the whole duration of the
operation.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5820
2023-09-18 22:04:32 +02:00
Benjamin Otte
f2a71898b1 array: Add gdk_array_steal()
Like gdk_array_clear() but returns the previous contents.
2023-09-15 16:34:00 +02:00
Benjamin Otte
60c20fa6ed vulkan: Require Vulkan 1.2
We need to inist on the nonuniform access beuing available and that
requires Vulkan 1.2.

Also simplifies the descriptor indexing stuff, because that's all part
of Vulkan 1.2, too.
2023-09-15 16:34:00 +02:00
Matthias Clasen
5441ed2227 Merge branch 'mcatanzaro/put-event' into 'main'
Fix documentation of gdk_display_put_event()

See merge request GNOME/gtk!6383
2023-09-13 21:27:22 +00:00
Luca Bacci
609e1f54ef macOS: Clamp damage region to surface size
...in _gdk_macos_cairo_context_begin_frame ()

GdkMacosCairoContext needs regions that are clamped to the
actual surface size.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5812
2023-09-13 17:13:33 +02:00
Luca Bacci
f49d0fbbf6 macOS: Fix typos 2023-09-13 16:53:27 +02:00
Michael Catanzaro
dde47b7966 Fix documentation of gdk_display_put_event()
This function is deprecated, but we should still document it properly.
It appends, not prepends. This is clear enough from its implementation,
but also we have practical experience with WebKit in:

https://github.com/WebKit/WebKit/pull/8663

Matthias prefers to avoid the prepend, append, start, and end
terminology altogether.
2023-09-13 08:19:11 -05:00
Jonas Ådahl
aecc76d916 wayland: Bind correct xdg_wm_base version
Otherwise we won't get the suspend state.
2023-09-12 21:51:59 +08:00
Benjamin Otte
81821978ae Merge branch 'wip/otte/for-main' into 'main'
gltexture: Restore previous GL context

See merge request GNOME/gtk!6335
2023-08-25 21:44:17 +00:00
René de Hesselle
9aeb5be8ad gdk: Use subpixel_layout on macOS 2023-08-24 15:30:03 +02:00
Benjamin Otte
8aaecc3416 gltexture: Restore previous GL context
Texture downloads can be initiated due to the weirdest reasons - and if
they cause a GL context to be changed, it'd be basically unpredictable
when the GL context changes.

An example is the Cairo renderer - if it needs to draw a GL texture, it
will download it.

Now that no longer changes the GL context.
2023-08-24 05:00:29 +02:00
Matthias Clasen
efd597c6ed Merge branch 'default-get-current-image' into 'main'
Implement gdk_paintable_default_get_current_image ()

See merge request GNOME/gtk!6303
2023-08-23 10:53:12 +00:00
Matthias Clasen
c78b34649b wayland: Don't assume the shell protocol
The gtk_shell proxy will be NULL if the compositor
is not gnome-shell. Handle that without crashing.

Fixes: #6048
2023-08-22 08:27:23 -04:00
Khalid Abu Shawarib
79fa785dbc gdk/x11/clipboard: Fix Slist leak 2023-08-21 20:32:42 +03:00
Sergey Bugaev
e45cba13ed paintable: Implement gdk_paintable_default_get_current_image ()
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-08-18 11:10:22 +03:00
Xavier Claessens
d6a07cd617 meson: Add x11_dep to gtk4-x11 requires 2023-08-15 21:17:39 -04:00
Xavier Claessens
090e01b383 meson: Add wayland-client to gtk4-wayland requires 2023-08-15 13:35:46 -04:00
Benjamin Otte
73500f9ebb Merge branch 'wip/otte/for-main' into 'main'
treeviewcolumn: Set ascending class for ascending order

Closes #6002

See merge request GNOME/gtk!6277
2023-08-13 03:54:19 +00:00