Commit Graph

2997 Commits

Author SHA1 Message Date
Matthias Clasen
5b6b42b5a9 x11: Fix initialization mess
When prepare_gl fails in the right way (or the wrong way?), we
end up creating the leader window twice, and as a side effect,
creating two instances of the "Virtual core pointer" device, which
is bad news for grabs.

Fixes: #6840
2024-08-31 11:28:52 -04:00
Matthias Clasen
ae8a06cdca x11: Cosmetics
Don't return FALSE from a function returning a pointer.
2024-08-31 11:28:52 -04:00
Benjamin Otte
41cd0c6f13 gl: Fix initial EGL context creation on X11
After commit 447bc18c48 EGL on X11 broke.

But the handling of the GL context also was quite awkward because it was
unclear who was responsible for ensuring it got reset.

Change that by making gdk_gl_context_clear_current_if_surface() return
the context (with a reference because it might be the last reference) it
had unset, so that after changing EGL properties the code that caused
the clearing can re-make it current.

This moves the responsibility to the actual code that is dealing with
updating properties and frees the outer layers of code from that task.

And that means the X11 EGL code doesn't need to care and the code in the
Wayland backend that did care can be removed.

Related: !7662
Fixes: #6964 on X11
2024-08-29 01:31:47 +02:00
Benjamin Otte
b6c848d711 x11: Remove special casing from get_damage() call
This function is only ever called while inside a frame, so the check is
not necessary.
2024-08-10 01:40:45 +02:00
Sergey Bugaev
85830c059e Plug GTask leaks
The error-prone pattern seems to be:

  GTask *task = g_task_new (...);

  if (condition)
    {
      g_task_return_... (task, ...);
      /* need g_object_unref (task) here! */
      return;
    }

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-08-05 14:38:23 +03:00
Benjamin Otte
ab7d969700 gdk: Add color state arg to gdk_texture_download_surface()
All callers set it to SRGB at the moment.
2024-07-11 14:57:20 +02:00
Benjamin Otte
1b1e7f4296 drawcontext: Make begin_frame() set colorstate + depth
Make begin_frame() set a rendering colorstate and depth, and provide it
to the renderers via gdk_draw_context_get_depth() and
gdk_draw_context_get_color_state().

This allows the draw contexts to define their own values, so that ie the
Cairo and GL renderer can choose different settings for rendering (in
particular, GL can choose GL_SRGB and do the srgb conversion; while
Cairo relies on the renderer).
2024-07-11 14:57:20 +02:00
Matthias Clasen
8d5325b816 glx: Create srgb drawables if possible
Make our visual selection code prefer fbconfigs that are
'srgb framebuffer capable', and mark the surface as 'is srgb'
in this case.

This arranges things so that GSK knows not to use an offscreen
for converting contents back to srgb in the end.
2024-07-11 14:57:20 +02:00
Benjamin Otte
b707568fc1 egl: Pass depth through the fbconfig selection code
We still only differentiate between high bit depth or not, but we now
choose at the end instead of the start, which makes it easier to adapt
to a different method of choosing.
2024-07-11 14:57:20 +02:00
Dr. David Alan Gilbert
14f1a91bff gdk: Remove unused struct 'XPointerUngrabInfo'
'XPointerUngrabInfo' appears unused since
commit 26cbf87d7d ("New approach for grab tracking code")
Remove it.

Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
2024-05-12 01:06:31 +01:00
Matthias Clasen
e540022869 x11: Implement a missing method
Vulkan on X11 was getting spew for missing an empty_frame
implementation.
2024-04-29 12:12:22 -04:00
Matthias Clasen
c1327e2c1b gdk: Deprecate public cursor theme setters
No need for this api, we've made the frontend setter private
for a reason.
2024-04-20 07:50:10 -04:00
oreo639
ab33b56ec9 x11: Remove last_wmspec_check_time
In fetch_net_wm_check_window(), before updating the wmspec_check_window, a
check is performed to verify a 15s difference between last_wmspec_check_time
and the current monotonic time.

The comment suggests that this check is done to ensure that it doesn't check
for a new check window repeatedly over and over again. While that was the case
origionally, currently the last_wmspec_check_time only gets updated when
wmspec_check_window is set, which is already checked earlier, making the time
check useless.

This check causes issues on cold boots where gtk4 applications are not able
to obtain the wmspec_check_window until 15 seconds after boot, making gtk
unable to check for extended wm_hints during that time.

Fixes: #6558
2024-04-16 12:35:00 -07:00
Philip Withnall
680dba6524
gdk: Fix a maybe-uninitialized warning
If there somehow end up being no `supported_versions`, `ctx` would end
up being dereferenced before being initialised. While I think that’s
unlikely, the compiler doesn’t know that, so let’s just initialise the
variable unconditionally.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-12 12:03:29 +01:00
Matthias Clasen
d1bb1d091c Merge branch 'gdk-build-dep-fix' into 'main'
build: Add a missing dependency

Closes #6618

See merge request GNOME/gtk!7127
2024-04-11 20:57:34 +00:00
Matthias Clasen
6510b876d1 build: Add a missing dependency
Add the generated gdk headers to the sources for all the backends,
to guarantee that they are generated before the library is used.

Fixes: #6618
2024-04-11 15:47:38 -04:00
Hansem Ro
d90dc7f75e xi2: Fix incorrect input source type in Input debug message
This drops cursor and eraser source names to account for their removal
from GdkInputSource so that GDK_DEBUG=input debug message correctly
prints source type in X11 environment.

Fixes: c1d90273 ("gdk: Drop GDK_SOURCE_ERASER")
Fixes: 3285f52d ("gdk: Drop GDK_SOURCE_CURSOR")
Closes: #6619
2024-04-08 10:15:00 -07:00
Matthias Clasen
80811069ac x11: Handle callback cursors
For these cursors, get the texture for the cursor image by
calling the callback. We always use scale 1.
2024-04-04 01:07:28 +02:00
Khalid Abu Shawarib
44fa748826 general: Fix leaks 2024-02-27 22:01:41 +03:00
Matthias Clasen
e6a4cc8ba2 x11: Shadows require compositing
We can only do client-side shadows if we have an rgba visual
and a compositing wm.

Fallout from 6e7893d5.

Fixes: #6464
2024-02-21 12:35:02 -05:00
Ben Mather
cb652c7f0f x11: Read window position relative to root window rather than parent
This fixes monitor enter and leave events on X11, and probably other
things.  Previously, it looks like the coordinates were relative to the
top left corner of the window shadow and so never changed.
2024-02-19 14:21:57 +00:00
Benjamin Otte
305ef51684 x11: Fix memleak
Fixes #6404
2024-02-07 07:03:59 +01:00
Arjan Molenaar
6e7893d527 Let GdkDisplay decide if shadows should be drawn
Replace the `#ifdef` blocks by a backend call.
2024-01-25 12:09:10 +01:00
Florian Müllner
bf0120f73d switch: Follow "show-status-shapes" setting
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
2024-01-11 01:33:16 +01:00
Matthias Clasen
3f513f3cc7 x11: Add a forgotten empty_frame implementation
This was causing warnings when using GLX.
2024-01-06 09:36:25 -05:00
Matthias Clasen
2dcec44714 Drop the nograbs debug value
This was only used in the x11 backend, and I haven't seen it
actively recommended for debugging anything in ages.
2023-11-20 08:02:03 -05:00
Matthias Clasen
f04c819439 Drop the gl-legacy debug value
The consensus is that we can do without this.
2023-11-20 08:02:02 -05:00
Matthias Clasen
4bdc44f4af Revert "Conditional check for gdesktopappinfo header"
This reverts commit 13b94dab10.

As pointed out in #6557, this commit is broken and causes
gio/gdesktopappinfo.h to never be found.
2023-11-14 23:45:17 -05:00
Benjamin Otte
310ab7b531 Remove G_ENABLE_DEBUG around debug checks
It started out as busywork, but it does many separate things. If I could
start over, I'd take them apart into multiple commits:

1. Remove G_ENABLE_DEBUG around GDK_DEBUG_*() calls
   This is not needed at all, the calls themselves take care of it.

2. Remove G_ENABLE_DEBUG around profiling code
   This now enables profiling support in release builds.

3. Stop poking _gdk_debug_flags and use GDK_DEBUG_CHECK()
   This was old code that was never updated.

4. Make !G_ENABLE_DEBUG turn off GDK_DEBUG_CHECK()
   The code used to
     #define GDK_DEBUG_CHECK(...) false
     #define GDK_DEBUG(...)
   which would compile away all the code inside those macros. This
   means a lot of variable definitions and debug utility functions
   would suddenly no longer be used and cause compiler errors.
2023-11-05 11:16:23 +01:00
Khalid Abu Shawarib
79fa785dbc gdk/x11/clipboard: Fix Slist leak 2023-08-21 20:32:42 +03:00
Xavier Claessens
d6a07cd617 meson: Add x11_dep to gtk4-x11 requires 2023-08-15 21:17:39 -04:00
Jonas Ådahl
7f946eff01 gtk: Add suspended window state
This is implemented using a new xdg_toplevel `suspended` state, and is
meant for allowing applications to know when they can stop doing
unnecessary work and thus save power.

In the other backends, the `suspended` state is set at the same time as
`minimized` as it's the closest there is to traditional windowing
systems.
2023-07-30 11:40:09 +03:00
Benjamin Otte
090cd2238a gdk: Replace prefers_high_depth with depth
Now that we track depth, we can also pass it into the GDK frame code.

For now it's just passed along, code acts the same as with
prefers_high_depth.
2023-06-18 14:28:39 +02:00
Benjamin Otte
e580dcf18d glx: Fake an X request to make GLX hack work
Sometimes, GLX can decide to use the previous request serial when faking
XErrors via __glXSendError() (look through the Mesa sources to enjoy).
This can cause the error trap we just installed to not feel responsible
for the error. And that makes GDK decide to immediately abort the
application.
That is not what we or GLX want.

So we use a no-op X Request to bump the request number so that when GLX
does its shenanigans, it uses a serial that our error trap will catch.

Fixes a crash in mutter's CI which apparently manages to drive GLX
without an X server.
2023-06-06 05:20:34 +02:00
Benjamin Otte
14e44f36bf glx: Move error trap even further out
This way we only create one error trap for all attempts to create a
context instead of up to 3.
2023-06-06 05:20:34 +02:00
Benjamin Otte
1e60ad1430 glx: Ignore all errors
In error cases, glXCreateContextAttribsARB() will always return NULL so
it is enough to run the loop until the first non-NULL context is
returned.

And at that point, we can just look at the return value and ignore all
errors.
2023-06-06 05:20:34 +02:00
Matthias Clasen
c380d17621 Revert "gdk/x11: Also grab keyboard during XDnD grabs"
This reverts commit ae94417f80.
2023-06-03 12:25:25 -04:00
Matthias Clasen
686d18dfc2 x11: Stop using passive grabs
The keynav that this implements is half-broken under
xwayland anyway, and it confused and complicates things
on the compositor side.
2023-06-03 12:25:25 -04:00
Benjamin Otte
0a1702ae99 Merge branch 'wip/otte/fix-glx' into 'main'
glx: Trap errors inside loop

Closes #5857

See merge request GNOME/gtk!6056
2023-06-03 16:19:09 +00:00
Benjamin Otte
0016fea36b glx: Trap errors inside loop
Instead of trapping errors for the whole loop trying to create GL
contexts, trap them once per GL context.

Apparently GLX does throw an error when a too high version is requested
and doesn't just return NULL and then that error lingers when we try
lower versions.

Fixes #5857
2023-06-03 18:03:56 +02:00
Matthias Clasen
c8c895d160 Merge branch 'trap-bad-rr-errors' into 'main'
x11: Trap XRandr errors when getting outputs during init and update

See merge request GNOME/gtk!6046
2023-06-02 11:31:45 +00:00
Marco Trevisan (Treviño)
f2a2889153 x11: Trap XRandr errors when getting outputs during init and update
We may try to update the XRR outputs and Crtcs when they're changing in
the server, and so we may get BadRROutput that we're currently not
handling properly.

As per this, use traps and check whether we got errors, and if we did
let's ignore the current output.

It's not required to call init_randr13() again because if we got errors
it's very likely that there's a change coming that will be notified at
next iteration during which we'll repeat the init actions.
2023-06-02 00:30:14 +02:00
Marco Trevisan (Treviño)
be4f6ff3da gdkselectioninputstream-x11: Explicitly handle stream ownership in signal
The display xevent signal connection takes the ownership of the stream
until we get a valid event, so it should manage the stream lifetime.

So make this clearer, by automatically removing the stream reference
when we disconnect from the xevent signal handler.
2023-05-30 17:59:19 +02:00
Marco Trevisan (Treviño)
4fcf899852 gdkselectioninputstream-x11: Make it clearer how we manage the stream ownership
It gets unreffed during gdk_x11_selection_input_stream_complete, so use
APIs that make this clearer.
2023-05-30 17:54:29 +02:00
Marco Trevisan (Treviño)
371e860184 gtkselectioninputstream-x11: Do not add an extra reference to the returned stream
We create a new stream during gdk_x11_selection_input_stream_new_async()
then such stream is referenced when passed to the task via
g_task_return_pointer(), so there's no need to reference it again before
returning it, or we'd end up leaking.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4892
2023-05-30 17:50:56 +02:00
Marco Trevisan (Treviño)
bce1e0bfdd gtkselectioninputstream-x11: Do not add unreffed bytes to the chunks queue
This should never happen, but we may exit the loop because of count value
with an unreffed bytes pointer being added back to the chunks queue.
2023-05-30 17:43:57 +02:00
Marco Trevisan (Treviño)
468d2cb7f2 gtkselectioninputstream-x11: Do not add EOF marker twice to the chunks queue
We were adding the same EOF marker two times back to the chunks queue,
one implicitly, and the other time could happen when exiting the loop.
2023-05-30 17:42:59 +02:00
Benjamin Otte
c7b62d89e3 glx: Implement support for EXT_swap_control
XWayland (at least on gnome-shell) does not support SGI_swap_control,
which we were using to unset the swap interval.

It does support EXT_swap_control though, which is the more modern
version of the same thing, so this commit adds support for that.

And now GDK_DEBUG=no-vsync gives me >1000fps instead of just 60fps,
2023-05-24 21:44:43 +02:00
Benjamin Otte
7573a9d2a7 gl: Rewrite update area tracking code
Make it more generic. That way we could dynamically change the number of
buffers we track.

We don't do that yet though.
2023-05-24 21:44:29 +02:00
Matthias Clasen
e5f1e4545d gdk: Change the private export handle api
Make unexport_handle take the handle, so we
can in the future deal with multiple exports.

Update the one caller in gtkwindow.c to pass
the handle.
2023-05-14 23:49:44 -04:00