GdkSurface maintains state that shadows the actual window state.
This state is not always updated in the macos backend.
In our case, when a window is initially maximized, `setFrame:display:`
was called and `inMaximizeTransition` was set. However,
`windowDidEndLiveResize:` was never called and `inMaximizeTransition`
was never unset, making the application think the window is still
maximized.
Additionally, `windowShouldZoom:toFrame:` is only called when the window
is maximized, not when it's unmaximized.
By checking and setting the state in `windowDidResize:` we can at least
be sure that the internal maximized state is only set if the window
takes up all desktop space: the screen's visible frame.
Currently dmabuf_dep is found when the following conditions are met:
- linux/dma-buf.h is present;
- libdrm is found.
This is because Linux dmabuf support requires drm_fourcc.h which is part
of libdrm.
However, dmabuf_dep is used for two purposes:
- define HAVE_DMABUF to state dmabuf support;
- ensure the presence of drm_fourcc.h for gdk and for the
media-gstreamer module.
Decouple this, unconditionally check for libdrm and require it on
Linux. Then, use libdrm_dep only to state the drm_fourcc.h presence.
Given that now we unconditionally require libdrm on Linux, HAVE_DMABUF
depends only on the linux/dma-buf.h presence.
This will let us use a subset of the full texture, which can
be necessary in the case that converters put padding around
content in dmabufs. The naming follows the Wayland viewporter
spec.
For now, make all callers pass the full texture rect.
We are going to introduce another rect, so better to be clear in
naming. We are following the naming of the Wayland viewporter spec
and call the rectangle that we drawing into the dest(ination).
Random code can call that function and cause unexpected GL context
changes. This is especially bad because it can happen nested.
Fixes the NGL renderer breaking in the inspector when importing a dmabuf
initializes the dmabuf backend which creates a GL renderer which creates
a GL context and makes it current causing the NGL renderer to break when
it continues rendering.
Fixes#6398
The 'icon_list' implementation of gtk+3 was somehow dropped
during the early conversion of GdkWindow to GdkSurface for gtk4.
Add it again, with minor tweaks to support GdkSurface.
Share the GdkTexture-to-HICON internal API with GdkCursor.
This allows 'gtk_window_set_icon_name()' to work on win32.
Expose information about if an event is handled to the backends.
This will allow a backend to deal with unhandled events, such as
macOS' default key bindings.
The first time this function is called, has_xdg_output() returns
true, but haven't yet received all the xdg-output events, so wait
for that to be done. Otherwise, the logical size is 0, and nothing
useful comes from that.
This fixes a problem that is apparent in
https://bugzilla.mozilla.org/show_bug.cgi?id=1869724, but that also
reproduces on any GTK application as described in
https://bugzilla.mozilla.org/show_bug.cgi?id=1869724#c16.
xdg_output sizes might be physical if the compositor doesn't scale them,
it seems. So to report the correct logical geometry in GDK pixels, we
need to detect this case. We do this by checking whether the wl_output
size matches the xdg_output size.
According to the Mesa developers, the correct way to determine
disjointness is to check the actual inode of the fd because dup()ing can
cause these duplications to happen when planes are carelessly copied or
when planes are sent over dbus or other unix sockets.
Related: https://bugs.webkit.org/show_bug.cgi?id=267578
We keep various pieces of double-buffered state on our side,
and then explicitly sync it over to the Wayland side.
Add a function to find out if we have any.
The ngl renderer has good support for fractional scaling, so we
can enable this by default now.
If you are using the gl renderer, you can disable fractional
scaling with the
GDK_DEBUG=gl-no-fractional
environment variable.
When a toplevel is focused programmatically and there is no
underlying seat, we cannot attempt to focus it with no
focus to be obtained, nor serials serials to use.
Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/6335
In GLES, BGRA is still done by GL_EXT_texture_format_BGRA8888 which is
an extension that is older than GLES 2.0.
And back then, internal formats had to be specified unsized. And when
that was changed with GLES3, nobody updated the extension.
However, on OpenGL, this extension doesn't exist, and internal formats
need to be sized.
So let's use different internal formats depending on GL version.
Fixes#6333
Whether or not switches include shapes to indicate their ON/OFF
state is currently controlled by the stylesheet (in particular
the HighContrast style).
However there are use cases for both using the HighContrast style
without shapes, and for using shapes with the regular stylesheet,
so follow the newly added "show-status-shapes" setting instead.
https://gitlab.gnome.org/GNOME/gtk/-/issues/5354
For tablet tools if we have NULL cursor, we use the default cursor
instead. This provides us with a tablet cursor when an application never
sets the cursor.
However, on proximity out when we clear said cursor we also
need to toggle off cursor_is_default, otherwise on the next proximity in
we assume we already have a cursor and never update it again.
This leads to an invisible cursor over GTK application when the tablet
tool is brought into proximity over the widget (but not when moving into
the widget from the outside).
Closes: #6312
If shaders don't support nonuniform indexing, we emulate it via if/else
ladders (or switch ladders) which get inlined by the GLSL compiles and
massively blow up the code.
And that makes compilation of the shaders take minutes and results in
shader code that isn't necessarily faster.
So we disable it on GL entirely and on Vulkan if the required features
aren't available.
As it's only an optimization and does not fall back to Cairo anymore,
this should be fine.
gdk_texture_save_to_png_bytes() cannot fail, so ensure that it doesn't.
Testsuite has been updated to check for this case.
Note that we do not load the PNG file that we generate here.
Loading is a lot more scary than saving after all.
If people want to load oversized PNG files, they should use a real PNG
loader.
This is using the Vulkan renderer.
It also allows claiming support for all the formats that only Vulkan
supports, but that neither GL nor native mmap can handle.
I did it because it unifies the code.
But it also gains the benefit of being debuggable because it can
now be turned off via GDK_VULKAN_SKIP=incremental-present
This ensures both that we signal a semaphore for a dmabuf when we export
an image and that we import semaphores for dmabufs and wait on them.
Fixes Vulkan node-editor displaying the Vulkan renderer in the sidebar.
This code does not add a downloader, so we do not claim support for all
the new formats.
It just queries the formats. But this can be used to import dmabufs
directly into the Vulkaan renderer.
use it to collect the optional features we are interested in and turn
them on only if available.
For now we add the dmabuf features, but we don't use them yet.
According to EXT_color_buffer_half_float it should be renderable, but it
fails to glGenerateMipmap() with Mesa 23.3 so just pretend it's not
renderable until that is fixed.
Fixes CI from failing.
I naively assumed the EXT_color_buffer_float and
EXT_color_buffer_half_float extensions would mirror each other, but they
do not. The float extension explicitly excludes RGB32F from the
renderable formats.
Doing this in a way that is picked up by gobject-introspection
requires splitting off new enum members into separate doc
comments, which is a bit unfortunate.
Some dmabuf formats were added in Vulkan 1.3.
Note that this does not require the Vulkan drivers to be version 1.3 -
it just means compilation against libvulkan 1.3
This makes no sense by itself, but we want to create the EGLImage at
DmabufTexture construction so that we can actually reject dmabufs that
we can't create EGLImages for.
This will make it possible to bail when the stride limitation for AMD
GPUs hits.
Instead of having an add_formats() function, make the get_downloader()
function add the formats.
This allows putting the actual downloader in a different place from the
initialization code.
This is done without testing, just doing my best to map all the DRM
formats to VkFormats.
Once people start using them, they'll figure it out when it's wrong.
(Somebody needs to write a testsuite.)
When we use the builtin downloads via mmap(), it's a special case where
we don't need to initialize subsystems and query them for support. We
know what we can and can't do.
Also, we want to use these formats with the lowest priority but pick the
downloader first for supported formats, and queueing it in the
downloaders list doesn't reflect that. So don't do it.
Track fallback formats to use in the memoryformat directly instead of
using in the GL uploading code.
First of all, this allows sharing the code and ensuring all our
renderers use the same fallback mechanism.
But also, this allows tracking fallbacks per-format which is useful
because the fallback formats aren't really a tree. We want to make
FLOAT16 fall back to FLOAT32 when not available, but we also want
FLOAT32 fall back to FLOAT16.
By tracking the fallbacks per-format, we can achieve that.
Add gdk_memory_format_get_premultiplied() and
gdk_memory_format_get_straight() which return the matching
premultiplied/straight format.
Use this to pick the premultiplied format when uploading GL textures.
And remove the duplication in the dmabuf code, where we can now use
these functions instead of tracking both the premultiplied and straight
alpha versions.
Add an "RGBA" format that just maps to the swizzled version of the
default format.
This way, BGR gets mapped to RGB + swizzling first before trying to map
it to the default format for the depth.
The benefit here is that this format has the same memory width, so
uploading/downloading code can treat it equivalent to the original
format and there's no conversion neccessary later.
Now that we have gdk_gl_context_get_memory_flags() and code can use that
function, make the code do that.
Remove support checks from gdk_memory_format_gl_format().
This is an initial naive port that doesn't try to make use of the finer-grained
flags yet.
Checks which features of a given memory format are supported by
the current GL implementation.
We check:
* usable: Can be used as a texture with NEAREST filter
* renderable: Can be used as a render target
* filterable: Can be used with GL_LINEAR
In normal GL, all formats are all of these things, but GLES is a lot
more picky.
So far nobody uses this.
If a subsurface is not below, it is visible no matter what the opaque
region is.
Also, we don't need to care about transparency in the subsurface if we
ignore it anyway. So this is a win-win.
We accept transparent subsurfaces for passthrough now, when they are
above the surface.
But we did not unset the opaque region to empty when the texture is
transprent.
That way, we can work with older libdrm versions.
The list was generated via a bit of sed and grep from the current
dmabuf-fourcc.h, which is why I put it into its own file and included
all the formats, no matter how old they are.
Add the matching GdkMemoryFormat for all dmabuf formats.
This way, we don't fall back to RGBA8 for 10- and 16-bit formats that we
don't support natively when EGL or Vulkan use them.
Also includes corrections for a few mixups.
Make this event behave like the other regular events, and emit
coordinates based on native surfaces. Fixes DnD over popovers
finding the correct coordinates.
This function takes an event, so the place(s) that do
not have one readily available can only pass NULL, so
the serial lookup will only work for the pointer.
Pass a device (plus optional sequence) to this function,
as these places do at least have the corresponding
GdkDevice at hand.
Fixes serial lookups for DnD, for other devices than
pointers (e.g. tablets, or touch).
Sadly, subsurface positioning is undefined in this case. We'll
trust the compositor to not mess up if the device coordinates
after applying the scale are integral, but otherwise, we'll
decline.
Instead, do it all in attach(), which becomes more and more like
ConfigureWindow. This is good, because it will let us take the
above-ness into account when making decisions about attaching.
There was one branch in the success case that turned it into a failure,
yet we were still reporting a success (and discarding the buffer).
Don't do that.
With the advent of dmabuf support, using GLES has become more
attractive, since we can use its external texture support to
support more dmabuf formats.
You can go back to the previous preference order by setting
GDK_DEBUG=gl-prefer-gl
The default keymap and keymap layouts are calculated on request.
If done once a surface is setup and listening at win32 events,
we may then enter in a recursive loop.
To avoid this, precalculate the keymap as soon as displays are open.
Fixes#6203Closes#6203
Add api to allow creating subsurfaces, attaching textures to them,
and changing the stacking order.
This is just the api, there is no implementation yet.
This is a backport of !1143 to gtk4.
SetClipboardViewer() API is obsolete is prone to clipboard chain breaks
from other applications.
Use recommended AddClipboardFormatListener() instead.
Fixes#442
Make sure all our dmabuf debug messages are display-scoped so the
inspector doesn't trigger them, use the same formatting throughout,
and improve consistency of wording here and there.
Getting this wrong matters, since we won't offload textures in
non-opaque formats. Found by Robert Mader. At the same time,
unify the two places we have for mapping from fourcc to memory
format.